import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { IsBoolean, IsInt, IsNotEmpty, IsOptional, IsString, IsUUID, MaxLength, Min } from 'class-validator';
import { ICreateMenu } from '@nbase/shared';

/**
 * 创建菜单 DTO
 */
export class CreateMenuDto implements ICreateMenu {
  @ApiProperty({
    description: '菜单名称',
    example: '系统管理',
    maxLength: 128,
  })
  @IsString()
  @IsNotEmpty()
  @MaxLength(128)
  name!: string;

  @ApiProperty({
    description: '权限标识',
    example: 'system:manage',
    maxLength: 128,
  })
  @IsString()
  @IsNotEmpty()
  @MaxLength(128)
  permission!: string;

  @ApiPropertyOptional({
    description: '菜单类型（1=菜单，2=按钮）',
    example: 1,
    default: 1,
  })
  @IsOptional()
  @IsInt()
  @Min(1)
  type?: number = 1; // 1.菜单 2.按钮

  @ApiPropertyOptional({
    description: '排序号',
    example: 0,
    default: 0,
  })
  @IsOptional()
  @IsInt()
  @Min(0)
  sort?: number = 0;

  @ApiPropertyOptional({
    description: '父菜单ID',
    example: 'uuid-parent',
  })
  @IsOptional()
  @IsUUID()
  parentId?: string;

  @ApiPropertyOptional({
    description: '路由路径',
    example: '/system',
    maxLength: 256,
  })
  @IsOptional()
  @IsString()
  @MaxLength(256)
  path?: string;

  @ApiPropertyOptional({
    description: '菜单图标',
    example: 'SettingOutlined',
    maxLength: 128,
  })
  @IsOptional()
  @IsString()
  @MaxLength(128)
  icon?: string;

  @ApiPropertyOptional({
    description: '组件路径',
    example: '@/views/system/index',
    maxLength: 256,
  })
  @IsOptional()
  @IsString()
  @MaxLength(256)
  component?: string;

  @ApiPropertyOptional({
    description: '是否可见',
    example: true,
    default: true,
  })
  @IsOptional()
  @IsBoolean()
  visible?: boolean = true;

  @ApiPropertyOptional({
    description: '是否缓存',
    example: false,
    default: false,
  })
  @IsOptional()
  @IsBoolean()
  keepAlive?: boolean = false;
}

